package com.atguigu.spzx.manager.controller.system;

import com.atguigu.spzx.manager.service.system.FileUploadService;
import com.atguigu.spzx.model.vo.common.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author Mahone
 */
@RestController
@RequestMapping("admin/system")
public class FileUploadController {

    @Autowired
    private FileUploadService fileUploadService;

    /**
     * 图片对象上传接口
     * @param multipartFile
     * @return
     */
    @PostMapping("/fileUpload")
    public Result fileUpload(@RequestParam("file")MultipartFile multipartFile){
       // 存储完成后，返回在存储服务器上的访问地址
        String url = fileUploadService.fileUpload(multipartFile);
        return Result.ok(url);
    }
}
